<link href="/theme/Default/css/postingFree/index.css" rel="stylesheet">
<script src="/theme/Default/js/jquery.validate.js"></script>
<script src="/theme/Default/js/PostingFree/index.js"></script>
<script src="/theme/Default/js/PostingFree/postingFreeValidate.js"></script>
<script src="/js/libnumber.js"></script>


<form action="<?php echo $action; ?>/<?php echo $data['Post']['id'];?>" method="post" id="postingFree">
	<div id="posting-free">
		<div class="posting_header">
			Nội dung tin <span class="posting_notice">(Vui lòng điền đầy đủ thông tin)</span>
		</div>
		<div class="posting_row">
			<div class="posting_label">
				Chuyên mục :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<select class="form-control" data-size="8" name="data[category_ids]" id="data_category_id">
						<option value="0">Chọn danh mục</option>
					    <?php
						    foreach ($rootCategories as $item){?>
								<optgroup value="<?php echo $item['RootCategory']['id']?>_" label="<?php echo $item['RootCategory']['category_name']?>">
								<?php
								foreach ($item['Category'] as $cat){?>
									<?php $val = $item['RootCategory']['id']."_".$cat['category_id'];?>
									<option value="<?php echo $val;?>"
										<?php echo $val == $data['Post']['category_ids']?"selected":"";?>
										><?php echo $cat['category_name']?></option>
								<?php	
								}?>
								</optgroup>
								<?php
						    }
						?>
				  	</select>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Bạn chưa chọn danh mục của tin</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Vùng :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<select class="form-control" data-size="8" name="data[region_id]" id="data_region_id">
						<option value="0">Chọn vùng</option>
					    <?php foreach ($regions as $item){?>
					    	<option value="<?php echo $item['Region']['region_id']?>"
					    		<?php echo $item['Region']['region_id']== $data['Post']['region_id']?"selected":""; ?>
					    		><?php echo $item['Region']['region_name']?></option>
					    <?php } ?>
				  	</select>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Bạn chưa chọn vùng của tin</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Bạn là :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<label class="radio-inline">
					  	<input type="radio" name="data[person_company]" id="radioCaNhan" value="2" 
					  	<?php echo $data['Post']['person_company']==2?"checked":""?>> Cá nhân
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[person_company]" id="radioCongTy" value="1"
					  	<?php echo $data['Post']['person_company']==1?"checked":""?>
					  	> Công ty
					</label>
				</div>
				<div class="category_group_warntip">
					
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Bạn đăng tin :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<label class="radio-inline">
					  	<input type="radio" name="data[buy_sell]" id="radioCanBan" value="2" 
					  	<?php echo $data['Post']['buy_sell']==2?"checked":""?>
					  	> Cần bán
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[buy_sell]" id="radioCanMua" value="1"
					  	<?php echo $data['Post']['buy_sell']==1?"checked":""?>
					  	> Cần mua
					</label>
				</div>
				<div class="category_group_warntip">
					
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Tựa đề :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input placeholder="Dùng tiếng việt có dấu" class="form-control" id="data_title" name="data[title_vn]" type="text" maxlength="50"  
					value="<?php echo $data['Post']['title_vn'] ?>"/>
				</div>
				<div class="category_group_warntip hide" style="display: none;">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Tựa đề phải dài ít nhất 2 ký tự</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Giá :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input placeholder="Giá bạn muốn bán" class="form-control" name="data[price]" type="text" value="<?php echo $data['Post']['price'] ?>" id="data_price" maxlength="15" data-v-max="999999999999" data-v-min="0" data-a-dec="."  data-a-sep=","/>
				</div>
				<div class="element-inline color-defaul">
					<label class="radio-inline">
					  	<input type="radio" name="data[currency_type]" id="radioCurrencyVnd" value="1"
					  	<?php echo $data['Post']['currency_type']==1?"checked":"";?>
					  	 checked> VND
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[currency_type]" id="radioCurrencyUsd" value="2"
					  	<?php echo $data['Post']['currency_type']==2?"checked":"";?>
					  	> USD
					</label>
				</div>
				<div class="category_group_warntip hide warn-price">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Thiếu giá tiền, vui lòng nhập số</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label label-top">
				Hình :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<div class="element-images">
						<div class="images-tip">“Trăm nghe không bằng mắt thấy”. Tin có hình được xem nhiều gấp 7 lần. 
							<br><b>ĐĂNG HÌNH ĐỂ BÁN CHẠY HƠN!</b>
						</div>
						<div class="row-3-image">
						<?php for ($i = 0; $i<6; $i++){?>
								<div class="one-image">
									<input class="postImage img<?php echo ($i+1)?>" type="file"/>
									<div class="image-upload">
										<span>Đăng hình</span>
									</div>
									<div id="image-success-<?php echo ($i+1)?>" class="image-up-success" style="<?php echo empty($img[$i])?"display: none":"" ?>">
										<img src="/<?php echo !empty($img[$i])? $img[$i]['Image']['url'] :"" ?>"/>
										<div class="remove-image delete<?php echo ($i+1)?>"></div>
									</div>
								</div>
							<?php if ($i==2){
								echo "</div><div class='row-3-image'>";
							} }?>
					</div>
				</div>
				<div class="category_group_warntip warn-image hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy chọn ít nhất 1 hình</span>
			    	</div>
				</div>
			</div>
		</div>
	</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Năm sản xuất :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[product_year]" type="text" id="data_product_year" maxlength="4"
					value="<?php echo $data['Post']['product_year'];?>" 
					/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập năm sản xuất</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label label-top">
				Tình trạng :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<label class="radio-inline">
					  	<input type="radio" name="data[product_status]" id="radioStateOld" value="1" 
					  	<?php echo $data['Post']['product_status']==1?"checked":"";?>
					  	> Đã qua sử dụng
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[product_status]" id="radioStateNew" value="2"
					  	<?php echo $data['Post']['product_status']==2?"checked":"";?>
					  	> Mới 100%
					</label>
				</div>
				<div class="category_group_warntip">
					
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Nước sản xuất :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[product_country]" type="text" value="<?php echo $data['Post']['product_country'];?>" id="data_product_country" maxlength="100"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập nước sản xuất</span>
			    	</div>
				</div>
			</div>
		</div>
		<div class="posting_row">
			<div class="posting_label">
				Thời gian đã sử dụng :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[time_used]" type="text" value="<?php echo $data['Post']['time_used'];?>" id="data_time_used" maxlength="3"/>
				</div>
				<div class="element-inline color-defaul">
					<label class="radio-inline">
					  	<input type="radio" name="data[time_used_type]" id="radioTimeYear" value="1"
					  	<?php echo $data['Post']['time_used_type']==1?"checked":"";?> 
					  	> Năm
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[time_used_type]" id="radioTimeHour" value="2"
					  	<?php echo $data['Post']['time_used_type']==2?"checked":"";?>
					  	> Giờ
					</label>
				</div>
				<div class="category_group_warntip hide warn-time">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập thời gian sử dụng</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label label-top">
				Thông tin về sản phẩm:
			</div>
			<div class="posting_element">
				<div class="element-main">
					<textarea placeholder="Điền thông tin sản phẩm (nếu có)" class="form-control" name="data[content]" rows="5">
						<?php echo $data['Post']['content'];?>
					</textarea>
				</div>
				<div class="category_group_warntip">
					
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Tên người bán :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[sell_name]" type="text" value="<?php echo $data['Post']['sell_name'];?>" id="data_sell_name"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập tên người bán</span>
			    	</div>
				</div>
			</div>
		</div>
		<div class="posting_row">
			<div class="posting_label">
				Di động / Phone :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[phone_number]" type="text" value="<?php echo $data['Post']['phone_number'];?>" id="data_phone_number" maxlength="11"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập số điện thoại</span>
			    	</div>
				</div>
			</div>
		</div>
		<div class="posting_row">
			<div class="posting_label">
				Email :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[mail_address]" type="text" value="<?php echo $data['Post']['mail_address'];?>" id="data_mail_address" maxlength="255"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập Email</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				
			</div>
			<div class="posting_element">
				<!--<input type="hidden" class="img_1 hdImg" name="data[img][0]"/>
				<input type="hidden" class="img_2 hdImg" name="data[img][1]"/>
				<input type="hidden" class="img_3 hdImg" name="data[img][2]"/>
				<input type="hidden" class="img_4 hdImg" name="data[img][3]"/>
				<input type="hidden" class="img_5 hdImg" name="data[img][4]"/>
				<input type="hidden" class="img_6 hdImg" name="data[img][5]"/>-->
				<?php for($i=0; $i<6; $i++){
					if(empty($img[$i])){
						echo "<input type='hidden' class='img_".($i+1)." hdImg' name='data[img][".$i."][url]'/>";
					}
					else{
						echo "<input type='hidden' class='img_".($i+1)." hdImg' name='data[img][".$i."][url]' value='".$img[$i]['Image']['url']."'/>";
						echo "<input type='hidden' name='data[img][".$i."][id]' value='".$img[$i]['Image']['id']."'/>";
					}
				 }?>
				<div class="element-main">
					<button type="submit" class="btn btn-danger">Đăng tin</button>
				</div>
			</div>
		</div>
		<div>
			
		</div>
	</div>
</form>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Thông báo</h4>
      </div>
      <div class="modal-body">
       
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" data-dismiss="modal">Đóng</button>
        <!-- <button type="button" class="btn btn-primary">Save changes</button> -->
      </div>
    </div>
  </div>
</div>